<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // [js] 写一个方法把下划线命名转成大驼峰命名
function toCamel(str) {
  return str.replace(/(\w)(_)(\w)/g, (match, $1, $2, $3) => `${$1}${$3.toUpperCase()}`)
}

console.log(toCamel('a_bc_def')) // aBcDef 
function  toCamelCase(str) {
  const demo = 'a_bc_def'.split('_').map(item =>{
    console.log(item);
    // console.log(item.charAt(0).toUpperCase());
    console.log(3123,item.substr(1, item.length));
  })
  console.log('a_bc_def'.split('_'));
  return str.split('_').map(item => item.charAt(0).toUpperCase() + item.substr(1, item.length))
    .join('');
}
console.log(toCamelCase('a_bc_def')) // aBcDef 

  </script>
</body>
</html>